﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection.Metadata;
using System.Text;
using System.Threading.Tasks;

namespace KingerRobot.PCRBW.SpiService;

public interface IRcsLocationRepositories
{
    #region 同步查询
    /// <summary>
    /// 根据Id查询实体
    /// </summary>
    /// <param name="objId"></param>
    /// <returns></returns>
    PORcsLocation QueryById(long objId);
    /// <summary>
    /// 根据id数组查询实体list
    /// </summary>
    /// <param name="lstIds"></param>
    /// <returns></returns>
    List<PORcsLocation> QueryByIDs(object[] lstIds);

    /// <summary>
    /// 添加
    /// </summary>
    /// <param name="model"></param>
    /// <returns></returns>
    int Add(PORcsLocation model);

    /// <summary>
    /// 批量添加
    /// </summary>
    /// <param name="listEntity"></param>
    /// <returns></returns>
    int Add(IEnumerable<PORcsLocation> listEntity);

    /// <summary>
    /// 根据id 删除某一实体
    /// </summary>
    /// <param name="id"></param>
    /// <returns></returns>
    int DeleteById(long id);


    /// <summary>
    /// 根据id数组，删除实体list
    /// </summary>
    /// <param name="ids"></param>
    /// <returns></returns>
    int Deletes(IEnumerable<PORcsLocation> entitys);

    /// <summary>
    /// 更新model
    /// </summary>
    /// <param name="model"></param>
    /// <returns></returns>
    int Update(PORcsLocation model);

    /// <summary>
    /// 根据model，更新，带where条件
    /// </summary>
    /// <param name="entity"></param>
    /// <param name="strWhere"></param>
    /// <returns></returns>
    int Update(Expression<Func<PORcsLocation, bool>> whereExpression, PORcsLocation entity);

    /// <summary>
    /// 正序查询第一条数据
    /// </summary>
    /// <returns></returns>
    PORcsLocation First();
    /// <summary>
    /// 根据条件查询查询第一条数据
    /// </summary>
    /// <param name="whereExpression"></param>
    /// <returns></returns>
    PORcsLocation First(Expression<Func<PORcsLocation, bool>> whereExpression);

    /// <summary>
    /// 查询
    /// </summary>
    /// <returns></returns>
    List<PORcsLocation> Query();


    /// <summary>
    /// 根据表达式查询
    /// </summary>
    /// <param name="whereExpression"></param>
    /// <returns></returns>
    List<PORcsLocation> Query(Expression<Func<PORcsLocation, bool>> whereExpression);
    /// <summary>
    /// 根据sql语句查询
    /// </summary>
    /// <param name="strSql">完整的sql语句</param>
    /// <param name="parameters">参数</param>
    /// <returns>泛型集合</returns>
    List<PORcsLocation> QuerySql(string strSql, Parameter[] parameters = null);
    /// <summary>
    /// 根据sql语句查询 执行update、delete、add
    /// </summary>
    /// <param name="strSql">完整的sql语句</param>
    /// <param name="parameters">参数</param>
    /// <returns>泛型集合</returns>
    int ExecuteSqlRaw(string strSql, Parameter[] parameters);

    #endregion
    /// <summary>
    /// 查询最近距离滑台最近的货位
    /// </summary>
    /// <param name="mesProduct"></param>
    /// <param name="rcsLoction"></param>
    /// <returns></returns>

    POWcsEquipLocHold GetDistancePoint(MesProduct mesProduct, PORcsLocation rcsLoction);
    /// <summary>
    /// 获取可以出库的货位
    /// </summary>
    /// <param name="whereExpression"></param>
    /// <returns></returns>
    (PORcsLocation, int) QueryStartLocation(Expression<Func<PORcsLocation, bool>> whereExpression);
    /// <summary>
    /// 人工出库
    /// </summary>
    /// <param name="whereExpression"></param>
    /// <returns></returns>
    PORcsLocation QueryLocation(Expression<Func<PORcsLocation, bool>> whereExpression);
}
